package com.hr;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Transient;

import com.espirit.common.Form;
import com.espirit.eap.annotation.Dict;
import com.espirit.eap.annotation.DomainModel;
import com.espirit.finance.core.AcctTerm;
import com.espirit.finance.core.AcctTermCheckAware;

@Entity
@DomainModel
public class LeaveAppItem extends Form implements  AcctTermCheckAware{
	private static final long serialVersionUID = -5141608486414999149L;
	public static final String LEAVE_TYPE="leaveappitem_leavetype";
	
	public static final Integer LEAVE_TYPE_PERSONAL = 1;
	public static final Integer LEAVE_TYPE_SICK = 2;
	public static final Integer LEAVE_TYPE_MARRIAGE = 3;
	public static final Integer LEAVE_TYPE_MALERNLTY = 4;
	public static final Integer LEAVE_TYPE_ANNUAL = 5;
	public static final Integer LEAVE_TYPE_EXCHANGING = 6;
	public static final Integer LEAVE_TYPE_BEREVEMENT = 7;
	public static final Integer LEAVE_TYPE_OCCUPATION_INJURY = 8;
	public static final Integer LEAVE_TYPE_OTHERS = 9;
	
	public BigDecimal getHours() {
		return hours;
	}
	public void setHours(BigDecimal hours) {
		this.hours = hours;
	}


	@Dict(type=LEAVE_TYPE)
	public Integer getLeaveType() {
		return leaveType;
	}
	public void setLeaveType(Integer leaveType) {
		this.leaveType = leaveType;
	}

	public Date getBeginTime() {
		return beginTime;
	}
	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

	public Date getEndTime() {
		return endTime;
	}
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	private BigDecimal hours;
	private Integer leaveType;
	private Date beginTime;
	private Date endTime;

	@Override
	public boolean check(AcctTerm acctTerm) {
		if (acctTerm != null && acctTerm.getBeginDate() != null && this.beginTime != null){
			return acctTerm.getBeginDate().compareTo(this.beginTime) < 0;
		} else {
			return true;
		}
	}

	@Override
	@Transient
	public boolean isAccept() {
		return false;
	}

	@Override
	public void onWFStarted() {
		
	}

	@Override
	public void onWFAccept() {
		
	}

	@Override
	public void onWFReject() {
		
	}
	
}
